package com.lovo.psc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lovo.commom.CscRemote.ICscTenderVendorRemote;
import com.lovo.psc.bean.BidBean;
import com.lovo.psc.bean.TendersBean;
import com.lovo.psc.mapper.IBidMapper;
import com.lovo.psc.mapper.ITenderMapper;
import com.lovo.psc.service.IBidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class BidServiceImpl implements IBidService {
    @Autowired
    private IBidMapper bidMapper;
    @Autowired
    ICscTenderVendorRemote remote;
    @Autowired
    private ITenderMapper mapper;

    @Override
    public void updateSrc(String vendorName, int tendersId, String src) {
        QueryWrapper<BidBean>qw=new QueryWrapper<>();
        qw.eq("fk_tendersId",tendersId);
        BidBean bidBean=bidMapper.selectOne(qw);
        bidBean.setSrc(src);
        bidMapper.updateById(bidBean);


        QueryWrapper<TendersBean> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pk_tendersId", bidBean.getBidId());
        TendersBean tendersBean = mapper.selectOne(queryWrapper);
        remote.updateTenderVendor(vendorName,tendersBean.getIdNum(),src);
    }
}
